
grammar TypeDeclaration;
import BaseLexer,BaseGrammar,Type,Express,Statement;

program
    :
    typeDeclaration;

typeDeclaration
    :
    decorator* Export? Abstract? (Class|Interface|Enum) SimpleName genericTypeDeclaration? extendDeclaration? implementsDeclaration?
    OpenBrace bodyDeclarations? CloseBrace
    ;

genericTypeDeclaration
    :
    LessThan SimpleName (Comma SimpleName)* GreaterThan
    ;

extendDeclaration
    :
    Extends type
    ;

implementsDeclaration
    :
    Implements type (Comma type)*
    ;

bodyDeclarations
    :
    (
    constructorDeclaration
    |methodDeclaration
    |fieldDeclaration
    )*
    |enumValues
    ;

fieldDeclaration
    :
    decorator* modifierKeyword? Static? Readonly? SimpleName QuestionMark? (Colon type)? (Assign express)? SemiColon?
    ;

constructorDeclaration
    :
    Constructor OpenParen  parameterDeclarations?  CloseParen (Colon type)? (block|SemiColon)?
    ;

methodDeclaration
    :
    decorator* modifierKeyword? Static? Abstract? SimpleName OpenParen  parameterDeclarations?  CloseParen (Colon type)? (block|SemiColon)?
    ;

parameterDeclarations
    :
    parameterDeclaration (Comma parameterDeclaration)*
    ;

parameterDeclaration
    :
    decorator*  VarArgs?  SimpleName (Colon type)?
    ;

enumValues
    :
    enumValue (Comma enumValue)* Comma?
    ;

enumValue
    :
    SimpleName (Assign express)?
    ;

decorator
    :
    At type (OpenParen OpenBrace decoratorItem? (Comma decoratorItem)* CloseBrace CloseParen)?
    ;

decoratorItem
    :
    SimpleName Colon express
    ;


